To Define Nested Sub-Features
-
Create the table with one geometry column, one ID, one angle field, and one foreign key.
CREATE TABLE DEVICE
(Id NUMBER PRIMARY KEY,
LinkedID NUMBER,
NAME VARCHAR2(50),
GEOMETRY MDSYS.SDO_GEOMETRY);
-
Insert the table metadata in the Oracle Spatial metadata.
INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
VALUES (‘DEVICE', 'GEOMETRY',
MDSYS.SDO_DIM_ARRAY
(MDSYS.SDO_DIM_ELEMENT('X', 714099.913898663, 715312.343907550, 0.000000050),
MDSYS.SDO_DIM_ELEMENT('Y', 4908438.586694972, 4910715.465519385, 0.000000050)),
82247);
COMMIT;
-
Create the spatial index of type point to use rotation.
CREATE INDEX device_idx ON DEVICE(Geometry)
INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS ('layer_gtype=point');
-
Create the foreign key constraint defining the sub-feature.
alter table DEVICE
add constraint DEVICECABLE_FK
foreign key(LINKEDID)
references CABLE(ID)
ON DELETE CASCADE;
-
Create the table with no geometry column, one ID, and one foreign key.
CREATE TABLE NOGRAPHIC
(Id NUMBER PRIMARY KEY,
LinkedID NUMBER,
NAME VARCHAR2(50));
-
Create the foreign key constraint defining the non-graphical sub-feature.
alter table NOGRAPHIC
add constraint NOGRAPHICDEVICE_FK
foreign key(LINKEDID)
references DEVICE(ID)
ON DELETE CASCADE;